package com.example.administrator.scan2web;

import android.content.Context;
import android.content.Intent;
import android.webkit.JavascriptInterface;

/**
 * Created by Administrator on 2017/5/25.
 */

public class AndroidJs extends Object {

    private Context context;

    public AndroidJs(Context context) {
        this.context = context;
    }

    // 定义JS需要调用的方法
    // 被JS调用的方法必须加入@JavascriptInterface注解
    @JavascriptInterface
    public void hello(){
        System.out.println("JS调用了Android的hello方法");
        context.startActivity(new Intent(context,SplashActivity.class));
        ((WebActivity)context).finish();
    }
}
